import os
import subprocess


def resize_to_4kx3k(filepath, newfilepath):
    if not os.path.exists(filepath):
        raise "{} 不存在".format(filepath)
    if os.path.exists(newfilepath):
        return
    command = 'ffmpeg -i {} -vf "scale=4000:3000" {}'.format(filepath, newfilepath)
    # 将标准输出和标准错误输出重定向到管道
    result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
